package com.apache.portal.contorller.bank;

import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import com.apache.api.vo.ResultMsg;
import com.apache.portal.common.restfull.RequestMapping;
import com.apache.portal.common.restfull.ResultFullAnntation;
import com.apache.portal.common.restfull.SupperAction;
import com.apache.portal.common.util.PortalPubFactory;
import com.apache.uct.common.LoginUser;
import com.apache.uct.common.PBOSSOTools;
import com.apache.uct.common.ToolsUtil;

@SuppressWarnings("serial")
@ResultFullAnntation(name = "bankAction", urlPatterns = "/bank/*")
public class BankAction extends SupperAction {
	protected void doInvoke(HttpServletRequest request, HttpServletResponse response, String methodType)
			throws Exception {
		String doCode = request.getParameter("doCode");
		LoginUser loginUser = PBOSSOTools.getLoginUser(request);
		if (ToolsUtil.isEmpty(loginUser)) {
			this.gotoLogin(request, response, "");
			return;
		}
		Method method = this.doInvoke(this.getClass(), request, response, methodType, doCode);
		if (null != method) {
			Object obj = method.invoke(this, request, response);
			if (!ToolsUtil.isEmpty(obj)) {
				JSONObject json = JSONObject.fromObject(obj);
				this.outputJson(json.toString(), response, request.getParameter("callback"));
			}
		} else {
			gotoErrorPage(request, response, "");
		}
	}

	/**
	 * 客户发起开户
	 * 异步 格式html
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000001", method = "post")
	protected ResultMsg BANK_CNP_T000001(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 对公账户绑定
	 * 异步 格式html
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000002", method = "post")
	protected ResultMsg BANK_CNP_T000002(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 对私银行卡在线绑定
	 * 异步 格式html
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000003", method = "post")
	protected ResultMsg BANK_CNP_T000003(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 平台发起客户提现
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000008", method = "post")
	protected ResultMsg BANK_CNP_T000008(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 客户发起销户
	 * 异步 格式html
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000011", method = "post")
	protected ResultMsg BANK_CNP_T000011(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 客户发起银行卡解除绑定
	 * 异步 格式html
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000017", method = "post")
	protected ResultMsg BANK_CNP_T000017(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 平台日终交易
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000022", method = "post")
	protected ResultMsg BANK_CNP_T000022(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 进入管理页面
	 * 异步 格式html
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_T000025", method = "post")
	protected ResultMsg BANK_CNP_T000025(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 平台文件生成通知
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_N000004", method = "post")
	protected ResultMsg BANK_CNP_N000004(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 账户信息查询
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_Q000001", method = "post")
	protected ResultMsg BANK_CNP_Q000001(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 资金明细查询
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_Q000002", method = "post")
	protected ResultMsg BANK_CNP_Q000002(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 银行卡绑定信息查询
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_Q000003", method = "post")
	protected ResultMsg BANK_CNP_Q000003(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 商户余额查询
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_Q000005", method = "post")
	protected ResultMsg BANK_CNP_Q000005(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 费用查询
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_Q000006", method = "post")
	protected ResultMsg BANK_CNP_Q000006(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 商户流水明细查询
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_Q000007", method = "post")
	protected ResultMsg BANK_CNP_Q000007(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 调用银行--文件下载
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_F000001", method = "post")
	protected ResultMsg BANK_CNP_F000001(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 本地--生成账户余额文件
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_FundBala", method = "post")
	protected ResultMsg BANK_CNP_FundBala(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 本地--生成余额变动文件
	 * 同步 格式json
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_BalaChg", method = "post")
	protected ResultMsg BANK_CNP_BalaChg(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}

	/**
	 * 本地--出入金明细对账
	 * @param request
	 * @param response
	 * @return
	 * @throws IOException
	 */
	@RequestMapping(value = "BANK_CNP_DZ", method = "post")
	protected ResultMsg BANK_CNP_DZ(HttpServletRequest request, HttpServletResponse response) throws IOException {
		Map<String, String> params = this.getParameterMap(request);
		ResultMsg msg = new ResultMsg();
		msg = (ResultMsg) PortalPubFactory.getInstance().getPlugin("bank").doInvoke(request, response, params);
		return msg;
	}
}
